package demo1;

public class demo_08Interrupt {
    public static void main(String[] args) throws InterruptedException {
        Thread thread =new Thread(()->{
            //只是一个标志位，修改标志位后是否中断，需要自己编译代码的时候符合逻辑
            while (!Thread.currentThread().isInterrupted()){
                //让线程时刻处于运行状态
                System.out.println("线程正在运行");
            }
        });
        //启动线程
        thread.start();
        //让线程运行一会
        Thread.sleep(5);
        //调用方法来中断线程
        thread.interrupt();
    }
}
